package day08;

import day07.PrimeNumber;

public class CarStation {
    public static void main(String[] args) {
        int a = calcSata("北京", "广州");
        System.out.println(a);
    }//计算

    //输入0-5
    public static int calcSata(String st1, String st2) {
        int[] price = new int[]{55, 180, 285, 195, 300};
        String[] address = new String[]{"珠海", "广州", "南昌", "上海", "北京", "黑龙江"};
        int firstIndex = 0;
        int toIndex = 0;
        for (int i = 0; i < address.length; i++) {
            if (address[i].equals(st1)) {
                firstIndex = i;
            }
            if (address[i].equals(st2)) {
                toIndex = i;
            }
        }
        System.out.println(firstIndex);
        System.out.println(toIndex);


        int priceReturn = 0;
        int interval = toIndex - firstIndex;
        if (interval > 1) {
            for (int i = firstIndex; i <= toIndex - 1; i++) {
                priceReturn += price[i];
            }
            return priceReturn;
        } else if (interval == 0) {
            return 0;
        } else if (interval == 1) {
            return price[interval];
        }
        if (interval < 0) {
            for (int i = toIndex; i <= firstIndex - 1; i++) {
                priceReturn += price[i];
            }
            return priceReturn;
        }
        return 0;
    }
}
